import React, { useState, useEffect } from 'react';
import axios from 'axios';

const EasyName = (param) => {
    const [stockInfo, setStockInfo] = useState(null);


    const getInfo = async () => {

        try {
            const response = await axios.get(`http://localhost:8084/stock/${param.param}`);
            setStockInfo(response.data.data.stockName)
        } catch (error) {
            console.error(error);
        }
    }

    useEffect(() => {
        getInfo();
    }, []); // 保证组件挂载时调用一次 getInfo

    return (
        <div>
             <p>{stockInfo}</p>
        </div>
    );
}

export default EasyName;